/**
 * @param {number[]} nums
 * @return {boolean}
 */
 var canJump = function(nums) {
    let len = nums.length,res=0
    for(let i=0;i<len;i++){
        let count =i+nums[i]
        res=Math.max(res,count)
        if(res>=len-1) return true
        if(res<=i) return false
        
    }
    return true
};
console.log(canJump([3,2,1,0,4]));